home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / comm / tlx_sq15.zip / UPLOAD.SLT < prev    next >
Text File  |  1991-02-02  |  31KB  |  893 lines

  1. //-----------------------------------------------------------
  2. // UPLOAD.SL? Automatic upload to BBSystems.
  3.  
  4. str DIR [6] = "CAT";     // Upload log subdirectory.
  5.  
  6. //-----------------------------------------------------------
  7. // The file <BBS>.UL must be placed in TELIX's program (main)
  8. // directory. The name <BBS> consists of the first 8 (max.) 
  9. // alphabetic characters of the BBS name.
  10. // The following parameters must be defined in this file:
  11.  
  12. // #:Conference number or name (optional)
  13. // F:Filename to upload.
  14. // D:Description of above file
  15. // D:Description of above file (cont.) 
  16. // D:Description of above file (cont.) 
  17. // #:Conference number or name (optional)
  18. // F:Next file to upload
  19. // D:Description of above file
  20. // D:Description of above file (cont.) 
  21. // D:Description of above file (cont.) 
  22. // etc.
  23.  
  24. // Example:
  25.  
  26. // #:XBOARD
  27. // F:GAME1.ZIP
  28. // D:Child's Play part one
  29. // F:GAME2.ZIP
  30. // D:Child's Play part two
  31. // #:Main
  32. // F:TXTFND.ZIP
  33. // D:Text finder program
  34.  
  35. // You may specify as many files as you want. The script attempts
  36. // to upload only the first MAXUP files. The description file is NOT
  37. // modified (successfully uploaded files are NOT deleted from the
  38. // list). Thus you may run the script repeatedly if you want to.
  39.  
  40. // You may also write as many specification lines as you want for
  41. // each file. However, there are a few things you should know:
  42. // PCBoard systems accept several lines for the description,
  43. // but each line is limited to 45 characters.
  44.  
  45. // The files to upload must be found either in the upload or down-
  46. // load directory defined in TELIX. If not, you MUST specify a
  47. // directory path with the filenames. The length of a filename
  48. // must not exceed 12 characters.
  49. // There is no check on the line length, so be aware!
  50.  
  51. // If you have suggestions for generalizing this script without
  52. // making it too complicated, please upload your new version to
  53. // this BBS, or suggest improvements via old-fashioned mail to:
  54.  
  55. //   Inge Vabekk
  56. //   Hamangskogen 108
  57. //   N-1300 SANDVIKA
  58. //   NORWAY                   
  59. //-----------------------------------------------------------
  60.  
  61. // Hint: Define a softkey to trigger this file.
  62.  
  63. str ul_spec    [12]          // Upload specifications.
  64.    ,upload_log [64]          // Name of upload log file.
  65.    ,bbs_type   [24]          // BBS type.
  66.    ,NextConf   [24]          // Next conference.
  67.    ,PrevConf   [24]          // Previous conference.
  68.    ,myprot      [2]          // My protocol.
  69.    ,hisprot     [2]          // His protocol.
  70.    ,input      [80]          // Input line.
  71.    ,runstr     [80]          // DSZ runstring.
  72.    ,file       [64]          // Path and filename.
  73.    ,description[80]          // Description.
  74.    ,f0         [64]          // Filename for upload.
  75.    ,f1         [64]          // Next filename.
  76.    ,command    [10]          // Command prompt.
  77.    ,temp        [4]          // Temporary for short strings.
  78.                              // For the Global storage:
  79.    ,global   []="GLOBAL"     // Global script.
  80.    ,join     []="JOINCONF"   // Join Conference script.
  81.    ,bbstype  []="BTYPE"      // BBS type.
  82.    ,short    []="SHORT"      // Short BBS name.
  83.    ,Cprot    []="CPROT"      // Current protocol.
  84.    ,Hprot    []="HPROT"      // "His" protocol.
  85.    ,version  []="PCBVER"     // PCB version
  86.    ,conf     []="CONF"       // Current conference
  87.    ,prompt   []="PROMPT"     // Current command prompt.
  88.    ,maxup    []="MAXUP"      // Max no. of files to upload
  89.    ,dsz      []="DSZ"        // DSZ parameters.
  90.    ;     
  91.  
  92. int tol = 600      // timeout limit is one minute.
  93.    ,tmark, stat 
  94.    ,infile         // Input file pointer
  95.    ,fstat          // Input file status:
  96.                    //  0: Description in "description"
  97.                    // >0: Length of filename in f0 or f1
  98.                    // <0: EOF read.
  99.    ,infilemenu     // in file menu if TRUE.
  100.    ,dline          // Description line number
  101.    ,pcb, mbbs, rbbs, opus, fido, crcs    // Possible BBS types
  102.    ,PCBver         // PCB version.
  103.    ,switched       // TRUE if conference switched.
  104.    ,max            // max. no. of files to upload.
  105.    ,protocol       // Must be INT!
  106.    ,usedsz         // = 1 (true) if we're using DSZ.
  107.    ;
  108.  
  109. //-----------------------------------------------------------
  110. // Upload script is entered here.
  111. //-----------------------------------------------------------
  112.  
  113. main()
  114. {
  115. int d, i, k, l;
  116.  
  117.   entry();                               // Updates colors & status bar. 
  118.  
  119. // Check if online.
  120. //-----------------------------------------------------------
  121.  
  122.   if (!carrier())   
  123.   { status_wind ("YOU CAN ONLY UPLOAD IF YOU'RE ONLINE!",20);
  124.     return(-1);
  125.   }
  126.  
  127.   newdir (_telix_dir);                   // Move to TELIX dir.
  128.  
  129. // Find BBS type (Set one logical variable).
  130.  
  131.   read (bbstype,input);                  // Get BBS type.
  132.   mbbs = pcb = rbbs = opus = fido = crcs = 0;
  133.   if      (input == "MBBS") mbbs = 1;
  134.   else if (input == "PCB" )
  135.   { pcb = 1;
  136.     read (version,temp);
  137.     PCBver = stoi (temp);                  // Get PCBoard version
  138.   }
  139.   else if (input == "RBBS") rbbs = 1;
  140.   else if (input == "OPUS") opus = 1;
  141.   else if (input == "FIDO") fido = 1;
  142.   else if (input == "CRCS") crcs = 1;
  143.   else                                          
  144.   { wrongBBS();                          // Doesn't match script!
  145.     return (-1);
  146.   }
  147.  
  148.   read (short,ul_spec);                  // Get the BBS's short name.
  149.   read (prompt,command);                 // Get command prompt.
  150.   read (cprot,myprot);                   // Get my and
  151.   protocol = subchr (myprot,0);
  152.   read (hprot,hisprot);                  // his protocol character.
  153.   read (conf,PrevConf);                  // Get conference.
  154.   if (pcb) NextConf = "Main Board";      // Join Main conference.
  155.  
  156. // Construct name of upload log and upload spec files.
  157. //-----------------------------------------------------------
  158.  
  159.   run ("CRDIR",DIR,2);                   // Create directory if necessary.
  160.   upload_log = DIR;                      // Set directory.
  161.   strcat (upload_log,"\");
  162.   strcat (upload_log,ul_spec);           // Add BBS name.
  163.   strcat (ul_spec,".UL");                // Add extension.
  164.  
  165. // Read upload specs.
  166.  
  167.   infile = fopen (ul_spec,"r");          // Read from upload spec.file.
  168.   if (infile==0) goto done;              // No such file!
  169.  
  170. // Start uploading.
  171. //-----------------------------------------------------------
  172.  
  173.   if (read (dsz,runstr) > 0            // Are we using DSZ?
  174.     && protocol == 'Z')
  175.   { strcat (runstr," sz ");            // Add parameters.
  176.     usedsz = 1;
  177.   }
  178.   else                             // No.
  179.     usedsz = 0;
  180.  
  181.   i = fstat = 0;
  182.   read (maxup,temp);
  183.   MAX = stoi (temp);
  184.   while (i < MAX && carrier())           // Upload files            
  185.   { while (!fstat)                       // Make sure a filename has
  186.       filename();                        // been read.
  187.     if (UL()) ++i;                       // If upload OK, count file.
  188.     if (fstat<0) i = MAX;                // Quit if EOF read.
  189.   }
  190.   fclose (infile);                       // Close the specification file.
  191.  
  192. done:
  193.   if (!carrier()) return (-1);           // Carrier lost...
  194.   fdelete (ul_spec);                     // Delete the upload file.
  195.  
  196.   if (mbbs && infilemenu)                // In the file menu, MBBS:
  197.   { waitfor (command,2);
  198.     cputs ("Q^M");                       // Quit.
  199.   }
  200.   else
  201.     flush();
  202.   return (0);
  203. }
  204.  
  205. //-----------------------------------------------------------
  206. // Routine to check if file exists and perform upload.
  207. //-----------------------------------------------------------    
  208.  
  209. // The routine returns zero for unsuccessful, and one for a
  210. // successful upload.
  211. // No message is given for files not found!
  212.  
  213. UL()
  214. {
  215. int ok, error;
  216.  
  217.   if (filename()) return (0);            // Return if no description.
  218.  
  219.   if (strchr(f1,0,'\') > 0)
  220.     file = f1;                           // Directory specified.
  221.   else
  222.   { file = _up_dir;                      // Not specified:
  223.     strcat (file,f1);